package com.bolt.report.business.modules.report.entity;

import com.bolt.report.business.modules.dataset.entity.ReportDataSetEntity;
import com.bolt.support.spring.jpa.entity.PersistableEntity;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Data;
import org.hibernate.annotations.GenericGenerator;

import javax.persistence.*;
import java.util.Set;

/**
 * Auto Generate Javadoc
 *
 * @author 日期:2021-11-22 17:47:51
 *         在线excel设计器
 **/
@Access(AccessType.FIELD)
@Entity
@Table(name = "bolt_report")
@Data
public class ReportEntity extends PersistableEntity<String> {

    @Id
    @GeneratedValue(generator = "hibernate-uuid")
    @GenericGenerator(name = "hibernate-uuid", strategy = "org.hibernate.id.UUIDGenerator")
    private String id;

    /**
     * 编码
     */
    @Column(name = "code", length = 50)
    private String code;

    /**
     * 名称
     */
    @Column(name = "name", length = 50)
    private String name;

    /**
     * 说明
     */
    @Column(name = "note", length = 255)
    private String note;

    /**
     * 状态
     */
    @Column(name = "status", length = 10)
    private String status;

    /**
     * 类型
     */
    @Column(name = "type", length = 10)
    private String type;

    /**
     * json字符串
     */
    @Column(name = "contextDef", length = 2147483647)
    private String contextDef;



    /**
     * 删除标识0-正常,1-已删除
     */
    @Column(name = "del_flag", length = 0)
    private Boolean delFlag;

    /**
     * 是否是模板 0-是,1-不是
     */
    @Column(name = "template", length = 0)
    private Boolean template;

    /**
     * 浏览次数
     */
    @Column(name = "view_count", length = 19)
    private Long viewCount;

    /**
     * css增强
     */
    @Column(name = "css_str")
    private String cssStr;

    /**
     * js增强
     */
    @Column(name = "js_str")
    private String jsStr;


    @ManyToMany(cascade = {CascadeType.PERSIST, CascadeType.MERGE})
    @JoinTable(name = "bolt_report2dbset",
            joinColumns = {@JoinColumn(name = "report_id", referencedColumnName = "id")},
            inverseJoinColumns = {@JoinColumn(name = "report_dataset_id", referencedColumnName = "id")})
    @JsonIgnore
    private Set<ReportDataSetEntity> dataSets;
}